package binaryfile;
/** 补码的演示 */
public class ComplementDemo {
    public static void main(String[] args) {
        /*
        规律数：
        int max = Integer.MAX_VALUE; //int的最大值
        int min = Integer.MIN_VALUE; //int的最小值
        System.out.println(Integer.toBinaryString(max)); //011111...
        System.out.println(Integer.toBinaryString(min)); //100000...
        System.out.println(Integer.toBinaryString(-1)); //111111...
        */

        //负值：用-1减去0位置的权
        int n = -45;
        //2进制显示11111111111111111111111111010011(-1-4-8-32=-45)
        System.out.println(Integer.toBinaryString(n));
        System.out.println(n);//10进制显示-45
    }
}
